package com.oak.broke.utils;

import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;

/**
 * @author tanghan
 * @Description 国际化消息提示信息工具类
 * @date 2023/04/13/ 14:26:00
 */
public class MessageUtil {

    private static MessageSource messageSource;

    static {
        messageSource = SpringContextUtil.getBean(MessageSource.class);
    }

    /**
     * 获取消息
     *
     * @param code code
     * @param args 参数
     * @return
     */
    public static String getMessage(Integer code, String... args) {
        return messageSource.getMessage(String.valueOf(code), args, LocaleContextHolder.getLocale());
    }
}
